package com.duvee.getInfo;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Properties;

/**
 * 从properties文件中读取数据
 * 
 * @author duvee 废弃20160324
 */
public class BaseGetProperty {
	String proName, appName;

	public BaseGetProperty(String proName, String appName) {
		this.proName = proName;
		this.appName = appName;
	}

	public String getStartActivity() {
		String appStartActivity = null;
		try {
			Properties prop = new Properties();// 属性集合对象
			// ClassLoader.getSystemResourceAsStream(proName);
			/*
			 * InputStream in = BaseGetProperty.class.getClassLoader()
			 * .getResourceAsStream(proName);
			 */
			InputStream ips = BaseGetProperty.class.getClassLoader()
					.getResourceAsStream("src/app.properties");
			/*
			 * InputStream ips2 = BaseGetProperty.class.getClassLoader()
			 * .getResourceAsStream("app.properties"); InputStream ips4 =
			 * Thread.currentThread().getClass()
			 * .getResourceAsStream("src/app.properties"); InputStream ips5 =
			 * Thread.currentThread().getClass()
			 * .getResourceAsStream("app.properties"); InputStream in2 =
			 * this.getClass().getClassLoader()
			 * .getResourceAsStream("src/app.properties"); InputStream in3 =
			 * this.getClass().getClassLoader()
			 * .getResourceAsStream("app.properties"); URL fileURL =
			 * this.getClass().getResource("app.properties");
			 */	/*
			 * 放到手机里面 InputStream ips6 = new BufferedInputStream(new
			 * FileInputStream( "com/duvee/getInfo/app.properties"));
			 * InputStream ips7 = new BufferedInputStream(new FileInputStream(
			 * "./app.properties")); InputStream ips8 = new
			 * BufferedInputStream(new FileInputStream( "app.properties"));
			 */
			BufferedReader ipss = new BufferedReader(new InputStreamReader(ips));
			prop.load(ipss);
			appStartActivity = prop.getProperty(appName);
			ipss.close();
			ips.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return appStartActivity;
	}
}
